const PREFIX = 'replay_'
const ReplayActionType = {
  toggle_show_type: PREFIX + 'toggle_show_type',
  init_swiper: PREFIX + 'init_swiper',
  change_swiper_index: PREFIX + 'change_swiper_index',
  init_qa_list: PREFIX + 'init_qa_list',
  update_voice_status: PREFIX + 'update_voice_status',
  stop_all_voice: PREFIX + 'stop_all_voice',
  update_footer: PREFIX + 'update_footer',
  set_dm_list: PREFIX + 'set_dm_list',
  toggle_big_image: PREFIX + 'toggle_big_image',
  update_no_audio: PREFIX + 'update_no_audio',
  reset_all_state: PREFIX + 'reset_all_state',
  do_self_like_item: `${PREFIX}do_self_like_item`,
  set_replay_marks: `${PREFIX}set_replay_marks`
}
const resetAllState = () => {
  return {
    type: ReplayActionType.reset_all_state
  }
}
const updateNoAudio = (type, value) => {
  return {
    type: ReplayActionType.update_no_audio,
    payload: {type: type, value: value}
  }
}
const toggleShowType = (type, show) => {
  return {
    type: ReplayActionType.toggle_show_type,
    payload: { type: type, show: show }
  }
}
const initSwiper = (images) => {
  return {
    type: ReplayActionType.init_swiper,
    payload: { images: images }
  }
}
const changeSwiperIndex = (index) => {
  return {
    type: ReplayActionType.change_swiper_index,
    payload: { index: index }
  }
}
const initQaList = (list) => {
  return {
    type: ReplayActionType.init_qa_list,
    payload: { list: list }
  }
}
const stopAllVoice = () => {
  return {
    type: ReplayActionType.stop_all_voice
  }
}
const updateVoiceStatus = (payload) => {
  return {
    type: ReplayActionType.update_voice_status,
    payload
  }
}
const updateFooter = (type, val) => {
  return {
    type: ReplayActionType.update_footer,
    payload: { type: type, value: val }
  }
}
const setReplayDmList = (dms) => {
  return {
    type: ReplayActionType.set_dm_list,
    payload: { list: dms }
  }
}
const toggleBigImage = (img) => {
  return {
    type: ReplayActionType.toggle_big_image,
    payload: { image: img }
  }
}

function doSelfLikeItem({msgType, id}) {
  return {
    type: ReplayActionType.do_self_like_item,
    payload: { msgType, id }
  }
}

function setReplayMarks(marks) {
  return {
    type: ReplayActionType.set_replay_marks,
    payload: {marks}
  }
}

module.exports = {
  ReplayActionType,
  toggleShowType,
  initSwiper,
  changeSwiperIndex,
  initQaList,
  updateVoiceStatus,
  updateFooter,
  setReplayDmList,
  toggleBigImage,
  updateNoAudio,
  resetAllState,
  stopAllVoice,
  doSelfLikeItem,
  setReplayMarks
}
